package com.beadhouse.nurrecord.web;

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;

import java.util.Map;

import org.apache.ibatis.annotations.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.beadhouse.common.dto.JSONResponse;
import com.beadhouse.common.dto.QueryResult;
import com.beadhouse.entity.CustomerAndNurcontentEntity;
import com.beadhouse.nurrecord.ao.NursingProjectAo;
import com.beadhouse.nurrecord.service.CustomerListService;
import com.beadhouse.nurrecord.service.NursingRecordsService;
import com.beadhouse.nurrecord.support.service.CustomerListServiceImpl;
import com.beadhouse.nurrecord.support.service.NursingProjectServiceImpl;
import com.beadhouse.nurrecord.support.service.NursingRecordsServiceImpl;

@Controller
@RequestMapping("/nurrecord")
public class CustomerListServlet {
	@Autowired
	CustomerListService clsi;
	@Autowired
	NursingRecordsService nrsi;
	
	@RequestMapping("/customerList.do")
	public ModelAndView customerList(NursingProjectAo ao){
		Integer pageNo = 1;
		Integer pageSize = 5;
		
		if(ao.getKey()!=null) {
			ao.setKey("%"+ao.getKey()+"%");
		}
		if(ao.getPageNo()!=null) {
			pageNo = Integer.parseInt(ao.getPageNo());
		}else {
			ao.setPageNo("1");
		}
		if(ao.getPageSize()!=null) {
			pageSize = Integer.parseInt(ao.getPageSize());
		}else {
			ao.setPageSize("5");
		}
		
		//用户列表
		QueryResult<Map<String, Object>> dto = clsi.selectAllCustomer(pageNo,pageSize,ao.getKey());
		JSONResponse result = new JSONResponse();
		result.setCode("ok");
		result.setData(dto);
		//护理记录
		ModelAndView mav = new ModelAndView();
		mav.setViewName("nurrecord/nurrecord");
		mav.addObject("date", result);
		
		return mav;
	}
	
	
}
